<?php
class Edit{
	/**
	 * ckeditor富文本编辑器配置类
	 * @param string $textareaid 要替换的textarea name
	 * @param string $toolbar 工具条：basic=标准版,full=全功能,desc简洁版
	 * @param int $height
	 * @param int $width
	 * @param string $color 
	 * @copyright www.hi121.com
	 * @author Melody 5735570@QQ.COM
	 * @return string [ckeditor config]
	 */
	public static function editor($textareaid = 'content', $toolbar = 'full', $color = '#e5e2fe' , $width=800 , $height = 230) {

		$file_upload=__GROUP__.'/Upload/ckupload';
		$flash_upload='';
		$str=null;
		$str='<script type="text/javascript" src="'.__ROOT__.'/Public/ckeditor/ckeditor.js">'."\r\n";
		$str.='</script>'."\r\n";
		$str.='<script type="text/javascript">'."\r\n";
		$str.='CKEDITOR.replace( "'.$textareaid.'",{'."\r\n";
		//自定义配置开始
		$str.= "toolbar :\r\n";
		$str.= "[\r\n";
		//自定义工具栏开始
		if($toolbar == 'basic') {
			$toolbar = "['Bold', 'Italic','Underline','Strike','NumberedList', 'BulletedList', 'TextColor','BGColor', 'Link', 'Unlink', '-', 'Image','Flash','Table','Smiley','SpecialChar'],['RemoveFormat'],
		   \r\n";
		} elseif($toolbar == 'full') {
		   $toolbar = "['Source'],
		    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
		    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['ShowBlocks'],['Image','Capture','Flash'],['Maximize'],
		    '/',
		    ['Bold','Italic','Underline','Strike','-'],
		    ['Subscript','Superscript','-'],
		    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
		    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
		    ['Link','Unlink','Anchor'],
		    ['Table','HorizontalRule','Smiley','SpecialChar'],
		    '/',
		    ['Styles','Format','Font'],
		    ['TextColor','BGColor','insertcode'],
		    ['attachment'],\r\n";
		  
		} elseif($toolbar == 'desc') {
			$toolbar = "['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'Image', '-','Source'],\r\n";
		} else{$toolbar = ''; }
		//自定义工具栏结束

		$str.=$toolbar;
		$str.= "],\r\n";
		$str.='uiColor:"'.$color.'",'."\r\n";
		$str.='filebrowserImageUploadUrl:'.'"'.$file_upload.'",'."\r\n";
		$str.='filebrowserFlashUploadUrl:'.'"FLASH上传路径",'."\r\n";
		$str.='skin: "kama", width:'.$width.', height:'.$height."\r\n";
		//自定义配置结束
		$str.='});'."\r\n";
		$str.='</script>'."\r\n";
		return $str;
	}

}